﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MaximPortal.Model;
using MaximServices.Model;
using MaximServices.Services;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace maxim_portal.Controllers
{
    /// <summary>
    /// 用户登录
    /// </summary>
    [EnableCors("AllowCors")]
    [Route("api/[controller]")]
    [ApiController]
    public class AccountController : ControllerBase
    {
        private SysuserServices _sysuserServices;
        public AccountController(SysuserServices sysuserServices)
        {
            _sysuserServices = sysuserServices;
        }

        // POST: api/Account
        [HttpPost]
        public ResultModel<LoginResultModel> Post([FromBody] AccountModel account)
        {
            try
            {
                return _sysuserServices.GetModel(account.name, account.mockDate);
            }
            catch (Exception e)
            {
                return BuildResult.Error(e.Message, default(LoginResultModel));
            }
        }
    }
}
